﻿<Window x:Class="FindDuplicateFile.DuplicateFileFinder"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:l="clr-namespace:FindDuplicateFile"
        xmlns:local="clr-namespace:FindDuplicateFile"
        Title="MainWindow" Height="550" Width="800">
    <Window.Resources>
        <l:FileAttribConverter x:Key="converter" />
        <Style TargetType="{x:Type DataGridRow}">
            <Style.Setters>
                <Setter Property="Background" Value="{Binding Path=StatusColor}"></Setter>
            </Style.Setters>
        </Style>
    </Window.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="50"></RowDefinition>
            <RowDefinition Height="30"></RowDefinition>
            <RowDefinition Height="*"></RowDefinition>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>            
            <ColumnDefinition Width="*"></ColumnDefinition>            
        </Grid.ColumnDefinitions>

        <StackPanel Name="lastStackPanel" Orientation="Horizontal" Grid.Row="0">
            <TextBox Name="folderPath" Height="23" Width="400" Margin="10 0 0 0" IsEnabled="False" ></TextBox>
            <Button Content="..." Height="23"  Name="selectPath" Click="selectPath_Click" Margin="3"></Button>
            <Button Content="Start" Height="23" Name="Calculate"  Width="75" Click="Button1_Click" />
            <ComboBox IsEditable="True" Height="23" Width="100" Name="fileExtension" Text="*">
                <ComboBoxItem Name="MP3">MP3</ComboBoxItem>
                <ComboBoxItem Name="Docx">Docx</ComboBoxItem>
                <ComboBoxItem Name="Xlsx">Xlsx</ComboBoxItem>                
            </ComboBox>
            <Grid Name="wpfProgressBarAndText" Height="25" Width="275" Visibility="Collapsed" >
                <ProgressBar Name="wpfProgressBar" IsIndeterminate="True" Minimum="0" Maximum="100" Width="250" Height="25" />
                <Viewbox>
                    <TextBlock Text='Processing, Please Wait....' />
                </Viewbox>
            </Grid>
            
        </StackPanel>
        <RadioButton Grid.Row="1" Margin="10 0 0 10" Name="rdbLength" IsChecked="True">Search through file Length</RadioButton>
        <RadioButton Grid.Row="1" Margin="200 0 0 10" Name="rdbHash" >Search through Hash</RadioButton>
                
        <!--  LoadingRow="dataGrid1_LoadingRow" -->
        <DataGrid Height="400" Name="dataGrid1" Width="602" Grid.Row="2" SelectionMode="Extended">                         
            <DataGrid.ContextMenu>
                <ContextMenu>
                    <MenuItem Header="Open Contain Folder" Click="MenuItem_Click_1" />
                    <MenuItem Header="Delete" Click="MenuItem_Click" />                    
                </ContextMenu>
            </DataGrid.ContextMenu>         
            <DataGrid.RowDetailsTemplate>
                <DataTemplate>
                    <StackPanel>
                        <TextBlock Text="No Record Found" Width="400"></TextBlock>
                    </StackPanel>
                </DataTemplate>
            </DataGrid.RowDetailsTemplate>
            <DataGrid.Style>
                <Style TargetType="DataGrid">
                    <Setter Property="RowDetailsVisibilityMode" Value="Collapsed"></Setter>
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding DataContext.IsRecordExists, 
                                    RelativeSource={RelativeSource Mode=FindAncestor,
                                    AncestorType={x:Type local:DuplicateFileFinder}}}" Value="false">
                            <Setter Property="RowHeight" Value="0"></Setter>
                            <Setter Property="RowDetailsVisibilityMode" Value="Visible"></Setter>
                        </DataTrigger>
                    </Style.Triggers>
                </Style>              
            </DataGrid.Style>
            <DataGrid.GroupStyle>
                <GroupStyle>                    
                    <GroupStyle.ContainerStyle>
                        <Style TargetType="GroupItem">
                            <Setter Property="Template">
                                <Setter.Value>
                                    <ControlTemplate TargetType="{x:Type GroupItem}">
                                        <StackPanel>
                                            <TextBlock FontWeight="Bold" Foreground="Blue" FontSize="16" Visibility="Hidden"
                                                      TextAlignment="Center" Text="{Binding DataContext.IsHashSearch,RelativeSource={RelativeSource AncestorType={x:Type DataGrid}},Converter={StaticResource converter}}" >                                              
                                            </TextBlock>
                                            <ItemsPresenter/>
                                        </StackPanel>
                                    </ControlTemplate>
                                </Setter.Value>
                            </Setter>
                        </Style>
                    </GroupStyle.ContainerStyle>
                </GroupStyle>
            </DataGrid.GroupStyle>
        </DataGrid>
    </Grid>
</Window>

